package com.controller;

import java.io.IOException;
import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@WebServlet("/hello")
public class HelloWorldServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			resp.setContentType("text/html;charset=utf-8");
			PrintWriter out = resp.getWriter();
			out.println("<html>");
			out.println("<head><title>HelloServlet</title></head>");
			out.println("<body>");
			out.println("<h1>helloWorld!</h1>");
			out.println("</body>");
			out.println("</html>");
	}

	@Override
	public void destroy() {
			System.out.println("servlet卸载!");
	}

	@Override
	public void init() throws ServletException {
		System.out.println("servlet初始化!");
	}
	
	
		
}
